<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="app">
    <p> 您好,<span id="name"></span></p>
</div>
<script>
    var obj = {}
    Object.defineProperty(obj, 'name', { //对象中的属性,配置get|set
        get: function () { //取值
            return document.getElementById('name').innerHTML
        },
        set: function (inner) { //设置改变值得内容
            document.getElementById('name').innerHTML = inner
        }
    })
    obj.name = 'xxxx'
</script>
</body>
</html>